package service

import (
	"github.com/gin-gonic/gin"
	"zk2/product-guard/internal/dto"
	"zk2/product-guard/internal/model"
	"zk2/product-guard/response"
)

func CreateWindowShop(c *gin.Context) {

	var WindowShop model.WindowShop
	err := c.ShouldBind(&WindowShop)
	if err != nil {
		response.Error(c, "参数错误")
		return
	}
	WindowShop = model.WindowShop{
		WindowId: WindowShop.WindowId,
		Name:     WindowShop.Name,
		Price:    WindowShop.Price,
		Num:      WindowShop.Num,
		Image:    WindowShop.Image,
	}
	if WindowShop.Name == "" || WindowShop.Price == 0 || WindowShop.Num == 0 {
		response.Error(c, "参数不能为空")
		return
	}
	err = dto.CreateWindowShop(&WindowShop)
	if err != nil {
		response.Error(c, "添加失败")
		return
	}
	response.Success(c, "添加成功", WindowShop.ID)
}
